
cmake_minimum_required(VERSION 3.5.1)

project(vscode-history-analyzer LANGUAGES CXX VERSION 0.0.4)

include(cmake/SparkEnvConfig.cmake)
include(cmake/SparkMacrosConfig.cmake)
include(cmake/SparkFindLibraries.cmake)
include(cmake/SparkFindQt5Config.cmake)
include(cmake/SparkFindQt6Config.cmake)

# 资源文件路径
set(QRC_SOURCES "")

spark_add_libraries_path(FileDirUtils utils/FileDirUtils)
target_link_qt5(FileDirUtils)

spark_add_executable_path(${PROJECT_NAME} src
    ${QRC_SOURCES}
)
target_link_FileDirUtils(${PROJECT_NAME})

include(cmake/SparkBuildGraphviz.cmake)

include(cmake/SparkDesktopMacros.cmake)
# 内容默认应用名称: Name=@PROJECT_NAME@ 与项目名称相同
spark_desktop_macros(
    # 应用名称: Name=
    "${PROJECT_NAME}" 
    # 应用名称: Name[zh_CN]=
    "VSCode 历史项目信息分析器" 
    # 应用说明: Comment=
    "一个可以帮助您了解 VSCode 历史项目信息的分析器" 
    # 应用类型: Type=
    "Application" 
    # 执行程序: Exec=
    "/usr/bin/${PROJECT_NAME}" 
    # 图标路径: Icon=
    "/usr/share/${PROJECT_NAME}/icon.png" 
    # 应用分类: Category=
    "Utility" 
)
install(FILES ${CMAKE_BINARY_DIR}/${PROJECT_NAME}.desktop
    DESTINATION /usr/share/applications)
install(FILES assets/icon.png
    DESTINATION /usr/share/${PROJECT_NAME})
install(TARGETS ${PROJECT_NAME}
    DESTINATION /usr/bin)

# 注释行(使用方式)
find_package(DebPackage PATHS ${CMAKE_SOURCE_DIR})
add_package_descript(cmake/package-deb.descript)


# 1. 在顶层构建中导入 Appimage 的构建
include(cmake/SparkAppimageConfig.cmake)  # 导入来自 Spark 构建的 Appimage 构建
add_appimage_icon(assets/icon.png)        # 添加到 Appimage 中的默认的图标
add_appimage_desktop()                    # 添加到 Appimage 中的默认desktop(使用来自 Spark 构建的 Desktop 构建中配置的信息(必须要求 spark-desktop))
add_appimage()                            # 应用对 Appimage 的构建
